package baseconfig

import (
	"github.com/gin-gonic/gin"
	"github.com/vueadmin/app/admin/internal/logic"
	"github.com/vueadmin/app/admin/internal/svc"
	"github.com/vueadmin/utils"
	"github.com/vueadmin/utils/response"
)

/**
 * @description(配置表单)
 * @buildcode(true)
 */
func Index(c *gin.Context, svcCtx *svc.ServiceContext) {
	l := logic.NewBaseconfigLogic(c, svcCtx)
	info, err := l.Index()
	if err != nil {
		response.Err(c, err)
		return
	}
	response.Success(c, "返回成功", info)
}

/**
 * @description(更新)
 * @buildcode(true)
 */
func Update(c *gin.Context, svcCtx *svc.ServiceContext) {
	var req map[string]interface{}
	if err := utils.BindAndValid(c, &req); err != nil {
		response.Err(c, err)
		return
	}
	l := logic.NewBaseconfigLogic(c, svcCtx)
	if err := l.Update(req); err != nil {
		response.Err(c, err)
		return
	}
	response.Success(c, "修改成功", nil)
}
